package io操作;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class 字符流 {
    public static void 字符输入流() throws IOException {
        FileReader fileReader = new FileReader("file.txt");
        char[] chars = new char[1024];
        int len;
        while ((len = fileReader.read(chars)) != -1) {
            System.out.print(new String(chars, 0, len));
        }
        fileReader.close();
    }
    public static void 字符输出流() throws IOException {
        FileWriter fileWriter = new FileWriter("file.txt",true);
        String[] data={"巧克力","香子兰","朝武芳乃"};
        for (String datum : data) {
            fileWriter.write(datum+"\r\n");
        }
        fileWriter.flush();
        fileWriter.close();
    }
    public static void main(String[] args) throws IOException {
        字符输出流();
        字符输入流();
    }
}
